<template>
  <div>
    <h3 @click="back">返回</h3>
    <van-checkbox-group v-model="$store.state.result">
      <van-row v-for="(item,index) in list"
        :key="index">
        <van-col span="4">
          <van-checkbox :name="item"></van-checkbox>
        </van-col>
        <van-col span="20">
          <van-card
            :num="item.num"
            :title="item.productName"
            :thumb="item.productImage"
            :price="item.salePrice"
          />
          <button @click="DEL(index)">删除</button>
        </van-col>
      </van-row>
    </van-checkbox-group>
    总价:{{$store.getters.total}}
    <van-checkbox v-model="checked" @click="ONCLICK">全选</van-checkbox>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      checked:false
    };
  },
  methods: {
    ONCLICK(){
      this.checked == !this.checked
      this.$store.dispatch('ONCLICK',this.checked)
    },
    DEL(index){
      this.$store.dispatch('DEL',index)
    },
    back(){
      this.$router.go(-1)
    }
  },
  mounted() {
    this.list = this.$store.state.CartList;
  },
};
</script>

<style>
</style>